/**
 * 获取滚动位置
 */
function getScrollingPosition() {
    var position = [0, 0];
    if (typeof window.pageXOffset != 'undefined') {
        position = [window.pageXOffset, window.pageYOffset];
    } else if (typeof document.documentElement.scrollTop != 'undefined' &&
        (document.documentElement.scrollTop > 0 || document.documentElement.scrollLeft > 0)) {
        position = [document.documentElement.scrollLeft, document.documentElement.scrollTop];
    } else if (typeof document.body.scrollLeft != 'undefined') {
        position = [document.body.scrollLeft, document.body.scrollTop];
    }
    return position;
}

/**
 * 获取窗口的大小
 */
function getViewportSize() {
    var size = [0, 0];
    if (typeof window.innerWidth != 'undefined') {
        size = [window.innerWidth, window.innerHeight];
    } else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined'
        && document.documentElement.clientWidth != 0) {
        size = [document.documentElement.clientWidth, document.documentElement.clientHeight];
    } else {
        var body = document.getElementsByTagName("body")[0];
        size = [body["clientWidth"], body["clientHeight"]];
    }
    return size;
}

/**
 * 获取光标位置
 */
function getCursorPosition(event) {
    var position = [0, 0];
    var scrollingPosition = getScrollingPosition();
    if (typeof event == "undefined") {
        event = window.event;
    }
    if (typeof event.pageX != 'undefined') {
        position = [event.pageX, event.pageY];
    } else {
        position = [event.clientX + scrollingPosition[0], event.clientY + scrollingPosition[1]];
    }
    return position;
}
